package com.hqyj.lls.controller;

import com.hqyj.lls.entity.MhSelect;
import com.hqyj.lls.entity.User;
import com.hqyj.lls.service.UserService;
import com.hqyj.lls.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

//@Controller
//@RequestMapping("/user")
@RestController
public class UserController {
    @Autowired
    private UserService userService;


    @RequestMapping("/user/{url}")
//    @RequestMapping("/toLogin")
//    @ResponseBody
    public ResultUtils login(@PathVariable String url,User user) {
        switch (url) {
            case "login":
                return userService.login(user);
            case "loginout":
                return userService.loginout();
            case "register":
                 return userService.register(user);
            case  "userList":
                return userService.userList(user);
            case "insert":
                return userService.insert(user);
            case "update":
                return userService.update(user);
            case "delete":
                return userService.deleteUpdByUserId(user);
            case "userDelList":
                return userService.userdelList(user);
            case "changeDel":
                return userService.changeDel(user);
            case "realDel":
                return userService.realDelUserAndRole(user);
            case "changeDelUserAll":
                return userService.changeDelUserAll(user);
            case "delUserAll":
                return userService.delUserAndRoleAll(user);
            case "managerList":
                return userService.managerList();
        }
        return null;
    }
    @RequestMapping("/search/mhselect")
    public ResultUtils mhselect(MhSelect mhSelect){
        return userService.mhselect(mhSelect);
    }

    @RequestMapping("/search/mhDelSelect")
    public ResultUtils mhDelSelect(User user){
        return userService.mhuserdelList(user);
    }
}
